package com.example.innovate.service.impl;

import com.example.innovate.domain.StarLevelDO;
import com.example.innovate.domain.StarLevelDOExample;
import com.example.innovate.mapper.StarLevelDOMapper;
import com.example.innovate.service.StarLevelService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StarLevelServiceImpl implements StarLevelService {
    @Autowired
    StarLevelDOMapper starLevelDOMapper;


    @Override
    public StarLevelDO addInfo(StarLevelDO starLevelDO) {
        starLevelDOMapper.insertSelective(starLevelDO);
        return starLevelDO;
    }

    @Override
    public void deleteInfo(int id) {
        starLevelDOMapper.deleteByPrimaryKey(id);
    }

    @Override
    public StarLevelDO updateInfo(StarLevelDO starLevelDO) {
        StarLevelDOExample starLevelDOExample = new StarLevelDOExample();
        starLevelDOMapper.updateByExampleSelective(starLevelDO,starLevelDOExample);
        return starLevelDO;
    }

    @Override
    public List<StarLevelDO> findAll(String modular, int PageNumber, int PageSize) {
        StarLevelDOExample starLevelDOExample = new StarLevelDOExample();
        StarLevelDOExample.Criteria criteria = starLevelDOExample.createCriteria();
        if(modular!=null){
            criteria.andStarModularEqualTo(modular);
        }
        PageHelper.startPage(PageNumber,PageSize);
        List<StarLevelDO> list = starLevelDOMapper.selectByExample(starLevelDOExample);
        return list;
    }
}
